<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function Student(stuId, stuName, stuAge) {
				this.stuId = stuId;
				this.stuName = stuName;
				this.stuAge = stuAge;
			}

			function logdo() {
				do {
					var userName = prompt("请输入用户名");
					var password = prompt("请输入密码");
					if (userName == "zhangsan" && password == "123") {
						break;
					}
				} while (true);
			}

			var flag = true;
			var arr = new Array();
			var login = prompt("1.登录2.退出");
			if (login == 1) {
				logdo();
				do {
					var choice = prompt("1.添加学生2.删除学生3.修改学生4.遍历学生5.退出");
					switch (choice) {
						case "1":
							var stuId = prompt("请输入学号");
							var stuName = prompt("请输入姓名");
							var stuAge = prompt("请输入年龄");
							var stu = new Student(stuId, stuName, stuAge);
							arr.push(stu);
							break;
						case "2":
							var stuId = prompt("请输入要删除的学生学号");
							arr = arr.filter(function(stu) {
								return stu.stuId != stuId;
							})
							break;
						case "3":
							var stuId = prompt("请输入要修改的学生学号");
							var stuName = prompt("请输入要修改的学生姓名");
							arr.forEach(function(stu) {
								if (stu.stuId == stuId) {
									stu.stuName = stuName;
								}
							})
							break;
						case "4":
							arr.forEach(function(stu) {
								var s = stu.stuId + "," + stu.stuName + "," + stuAge;
								alert(s);
							})
							break;
						case "5":
							flag = false;
							break;
					}
				} while (flag);
			}
			alert("谢谢!!!")
		</script>
	</head>
	<body>
	</body>
</html>
